package com.jomoo.common.tools;

import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.struts2.ServletActionContext;

import org.apache.commons.logging.Log;
import com.jomoo.common.pojo.JoMooCard;
import com.jomoo.common.pojo.JomooAccount;
import com.jomoo.common.utils.Constants;

/**
 * 导出Excel表公共工具类
 * 
 * @author haosc
 */
public class ExcelTool
{
	// 格式化时间为字符串yyyy-MM形式
	public static SimpleDateFormat format = new SimpleDateFormat(Constants.DATE_TIME_PATTERN);

	/** 创建表格 */
	@SuppressWarnings("unchecked")
	public static void createExcel(String strFileName, String strTitleName, @SuppressWarnings("rawtypes") List list,
			Log log, String strFlag)
	{
		HttpServletResponse response = ServletActionContext.getResponse();

		try
		{
			SimpleDateFormat simple = new SimpleDateFormat("yyyyMMddhhmmss");

			String fileName = new String(strFileName.getBytes("GBK"),
					"ISO8859_1")
					+ "_" + simple.format(new Date());

			/** 设置字符编码格式 */
			response.setCharacterEncoding("UTF-8");

			/** 设置输出格式 */
			response.setContentType("application/vnd.ms-excel;charset=GBK");

			/** 设置输出文件名 */
			response.setHeader("Content-Disposition", "attachment; filename="
					+ fileName + ".xls");

			/** 流定义 */
			OutputStream out = response.getOutputStream();

			/** 声明一个工作薄 */
			HSSFWorkbook hsf = new HSSFWorkbook();

			/** 生成一个表格 */
			HSSFSheet hsfe = hsf.createSheet();

			/** 产生表格标题行 */
			HSSFRow headrow = hsfe.createRow(0);

			headrow.setHeight((short) 360);

			/** 标题内容 (加非空判断，考虑有些表格不需要标题行) */
			if (null != strTitleName && !"".equals(strTitleName))
			{
				hsf.setSheetName(0, strTitleName, HSSFWorkbook.ENCODING_UTF_16);
			}

			/** 生成一个样式 */
			HSSFCellStyle style = createHSSFCellStyle(hsf);

			/** 生成一个样式 */
			HSSFCellStyle numStyle = createHSSFCellStyleForNum(hsf);

			/** 生成一个字体 */
			HSSFFont font = createSong(hsf);

			/** 设置表格字体 */
			style.setFont(font);

			if (strFlag.equals("card"))
			{
				createTitle(hsfe, headrow, style, list, numStyle, numStyle,
																			hsf, out, log);
			}

			if (strFlag.equals("account"))
			{
				createAccountExcle(hsfe, headrow, style, list, numStyle, numStyle,
																			hsf, out, log);
			}
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}

	// 普通字符单元格定义
	public static HSSFCellStyle createHSSFCellStyle(HSSFWorkbook hsf)
	{

		HSSFCellStyle headcellstyle = hsf.createCellStyle();

		// 设置这些样式
		headcellstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);

		// 定义单元格样式
		headcellstyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);

		// 返回样式
		return headcellstyle;
	}

	// 数据单元格格式化定义
	public static HSSFCellStyle createHSSFCellStyleForNum(HSSFWorkbook hsf)
	{

		HSSFCellStyle headcellstyle = hsf.createCellStyle();

		// 设置这些样式
		headcellstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);

		// 居中
		headcellstyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);

		// 定义格式
		headcellstyle.setDataFormat(hsf.createDataFormat().getFormat("#,##0"));

		// 定义后返回
		return headcellstyle;
	}

	public static HSSFFont createSong(HSSFWorkbook hsf)
	{
		/** 生成一个字体 */
		HSSFFont font = hsf.createFont();

		font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

		font.setFontName("宋体");

		font.setFontHeight((short) 230);

		return font;
	}

	// 创建标题
	public static void createTitle(HSSFSheet hsfe, HSSFRow headrow,
			HSSFCellStyle headcellstyle, List<JoMooCard> list,
			HSSFCellStyle numStyle, HSSFCellStyle style, HSSFWorkbook hsf,
			OutputStream out, Log log)
	{
		try
		{
			HSSFCell cell0 = headrow.createCell((short) 0);
			cell0.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell0.setCellStyle((HSSFCellStyle) headcellstyle);
			cell0.setCellValue("序号");

			HSSFCell cell1 = headrow.createCell((short) 1);
			cell1.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell1.setCellStyle((HSSFCellStyle) headcellstyle);
			cell1.setCellValue("客户姓名");

			HSSFCell cell2 = headrow.createCell((short) 2);
			cell2.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell2.setCellStyle((HSSFCellStyle) headcellstyle);
			cell2.setCellValue("客户电话");

			HSSFCell cell3 = headrow.createCell((short) 3);
			cell3.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell3.setCellStyle((HSSFCellStyle) headcellstyle);
			cell3.setCellValue("商品分类");

			HSSFCell cell4 = headrow.createCell((short) 4);
			cell4.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell4.setCellStyle((HSSFCellStyle) headcellstyle);
			cell4.setCellValue("商品型号");

			HSSFCell cell5 = headrow.createCell((short) 5);
			cell5.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell5.setCellStyle((HSSFCellStyle) headcellstyle);
			cell5.setCellValue("客户地址");

			HSSFCell cell6 = headrow.createCell((short) 6);
			cell6.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell6.setCellStyle((HSSFCellStyle) headcellstyle);
			cell6.setCellValue("安装状态");

			HSSFCell cell7 = headrow.createCell((short) 7);
			cell7.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell7.setCellStyle((HSSFCellStyle) headcellstyle);
			cell7.setCellValue("预约/维修时间");

			HSSFCell cell8 = headrow.createCell((short) 8);
			cell8.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell8.setCellStyle((HSSFCellStyle) headcellstyle);
			cell8.setCellValue("安装类型");

			HSSFCell cell9 = headrow.createCell((short) 9);
			cell9.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell9.setCellStyle((HSSFCellStyle) headcellstyle);
			cell9.setCellValue("金额（元）");

			HSSFCell cell10 = headrow.createCell((short) 10);
			cell10.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell10.setCellStyle((HSSFCellStyle) headcellstyle);
			cell10.setCellValue("备注");

			hsfe.setColumnWidth(Short.parseShort(0 + ""), Short
					.parseShort(1500 + ""));
			hsfe.setColumnWidth(Short.parseShort(1 + ""), Short
					.parseShort(3500 + ""));
			hsfe.setColumnWidth(Short.parseShort(2 + ""), Short
					.parseShort(4500 + ""));
			hsfe.setColumnWidth(Short.parseShort(3 + ""), Short
					.parseShort(2800 + ""));
			hsfe.setColumnWidth(Short.parseShort(4 + ""), Short
					.parseShort(2800 + ""));
			hsfe.setColumnWidth(Short.parseShort(5 + ""), Short
					.parseShort(7800 + ""));
			hsfe.setColumnWidth(Short.parseShort(6 + ""), Short
					.parseShort(3000 + ""));
			hsfe.setColumnWidth(Short.parseShort(7 + ""), Short
					.parseShort(6000 + ""));
			hsfe.setColumnWidth(Short.parseShort(8 + ""), Short
					.parseShort(3400 + ""));
			hsfe.setColumnWidth(Short.parseShort(9 + ""), Short
					.parseShort(3000 + ""));
			hsfe.setColumnWidth(Short.parseShort(10 + ""), Short
					.parseShort(6800 + ""));

			Float totalSale = 0.0f;

			for (int iIndex = 0; iIndex < list.size(); iIndex++)
			{
				JoMooCard ojc = (JoMooCard) list.get(iIndex);

				HSSFRow rows = hsfe.createRow(iIndex + 1);
				rows.setHeight((short) 350);

				HSSFCell hssfCell0 = rows.createCell((short) 0);
				hssfCell0.setCellStyle((HSSFCellStyle) numStyle);
				hssfCell0.setCellValue(iIndex + 1);

				/** 客户姓名 */
				HSSFCell hssfCell1 = rows.createCell((short) 1);
				hssfCell1.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell1.setCellStyle((HSSFCellStyle) style);
				hssfCell1.setCellValue(ojc.getPopName() == null ? "" : ojc
						.getPopName());

				/** 客户电话 */
				HSSFCell hssfCell2 = rows.createCell((short) 2);
				hssfCell2.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell2.setCellStyle((HSSFCellStyle) style);
				hssfCell2.setCellValue(ojc.getPopPhone() == null ? "" : ojc
						.getPopPhone());

				/** 商品分类 */
				HSSFCell hssfCell3 = rows.createCell((short) 3);
				hssfCell3.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell3.setCellStyle((HSSFCellStyle) style);
				hssfCell3.setCellValue(ojc.getProductTypeName() == null ? ""
						: ojc.getProductTypeName());

				/** 商品型号 */
				HSSFCell hssfCell4 = rows.createCell((short) 4);
				hssfCell4.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell4.setCellStyle((HSSFCellStyle) style);
				hssfCell4.setCellValue(ojc.getProductSpecName() == null ? ""
						: ojc.getProductSpecName());

				/** 客户地址 */
				HSSFCell hssfCell5 = rows.createCell((short) 5);
				hssfCell5.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell5.setCellStyle((HSSFCellStyle) style);
				hssfCell5.setCellValue(ojc.getPopAddress() == null ? "" : ojc
						.getPopAddress());

				/** 安装状态 */
				HSSFCell hssfCell6 = rows.createCell((short) 6);
				hssfCell6.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell6.setCellStyle((HSSFCellStyle) style);
				hssfCell6.setCellValue(ojc.getSetupStateName() == null ? ""
						: ojc.getSetupStateName());

				/** 预约/维修时间 */
				HSSFCell hssfCell7 = rows.createCell((short) 7);
				hssfCell7.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell7.setCellStyle((HSSFCellStyle) style);
				hssfCell7
						.setCellValue(format.format(ojc.getSetupTime()) == null ? ""
								: format.format(ojc.getSetupTime()));

				/** 安装类型 */
				HSSFCell hssfCell8 = rows.createCell((short) 8);
				hssfCell8.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell8.setCellStyle((HSSFCellStyle) style);

				if (1 == ojc.getSetupType())
				{
					hssfCell8.setCellValue("安装");
				}

				if (2 == ojc.getSetupType())
				{
					hssfCell8.setCellValue("维修");
				}

				/** 金额 */
				HSSFCell hssfCell9 = rows.createCell((short) 9);
				hssfCell9.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell9.setCellStyle((HSSFCellStyle) style);
				hssfCell9.setCellValue(ojc.getSale().toString() == null ? ""
						: ojc.getSale().toString());

				/** 备注 */
				HSSFCell hssfCell10 = rows.createCell((short) 10);
				hssfCell10.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell10.setCellStyle((HSSFCellStyle) style);
				hssfCell10.setCellValue(ojc.getRemark() == null ? "" : ojc
						.getRemark());

				if (null != ojc.getSale())
				{
					totalSale += ojc.getSale();
				}
			}

			/** 创建统计数据行 */
			HSSFRow Totalrows = hsfe.createRow(list.size() + 1);

			HSSFCell hssfCell0 = Totalrows.createCell((short) 0);
			hssfCell0.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell0.setCellStyle((HSSFCellStyle) style);
			hssfCell0.setCellValue("合计");

			/** 客户姓名 */
			HSSFCell hssfCell1 = Totalrows.createCell((short) 1);
			hssfCell1.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell1.setCellStyle((HSSFCellStyle) style);
			hssfCell1.setCellValue("--");

			/** 客户电话 */
			HSSFCell hssfCell2 = Totalrows.createCell((short) 2);
			hssfCell2.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell2.setCellStyle((HSSFCellStyle) style);
			hssfCell2.setCellValue("--");

			/** 商品分类 */
			HSSFCell hssfCell3 = Totalrows.createCell((short) 3);
			hssfCell3.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell3.setCellStyle((HSSFCellStyle) style);
			hssfCell3.setCellValue("--");

			/** 商品型号 */
			HSSFCell hssfCell4 = Totalrows.createCell((short) 4);
			hssfCell4.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell4.setCellStyle((HSSFCellStyle) style);
			hssfCell4.setCellValue("--");

			/** 客户地址 */
			HSSFCell hssfCell5 = Totalrows.createCell((short) 5);
			hssfCell5.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell5.setCellStyle((HSSFCellStyle) style);
			hssfCell5.setCellValue("--");

			/** 安装状态 */
			HSSFCell hssfCell6 = Totalrows.createCell((short) 6);
			hssfCell6.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell6.setCellStyle((HSSFCellStyle) style);
			hssfCell6.setCellValue("--");

			/** 预约/维修时间 */
			HSSFCell hssfCell7 = Totalrows.createCell((short) 7);
			hssfCell7.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell7.setCellStyle((HSSFCellStyle) style);
			hssfCell7.setCellValue("--");

			/** 安装类型 */
			HSSFCell hssfCell8 = Totalrows.createCell((short) 8);
			hssfCell8.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell8.setCellStyle((HSSFCellStyle) style);
			hssfCell8.setCellValue("--");

			/** 金额 */
			HSSFCell hssfCell9 = Totalrows.createCell((short) 9);
			hssfCell9.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell9.setCellStyle((HSSFCellStyle) style);
			hssfCell9.setCellValue(totalSale.toString());

			hsf.write(out);

			out.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
			log.error("服务卡导出异常：" + e.getMessage());
		}
	}

	public static void createAccountExcle(HSSFSheet hsfe, HSSFRow headrow,
			HSSFCellStyle headcellstyle, List<JomooAccount> list,
			HSSFCellStyle numStyle, HSSFCellStyle style, HSSFWorkbook hsf,
			OutputStream out, Log log)
	{
		try
		{
			HSSFCell cell0 = headrow.createCell((short) 0);
			cell0.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell0.setCellStyle((HSSFCellStyle) headcellstyle);
			cell0.setCellValue("序号");

			HSSFCell cell1 = headrow.createCell((short) 1);
			cell1.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell1.setCellStyle((HSSFCellStyle) headcellstyle);
			cell1.setCellValue("账单类型");

			HSSFCell cell2 = headrow.createCell((short) 2);
			cell2.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell2.setCellStyle((HSSFCellStyle) headcellstyle);
			cell2.setCellValue("结算状态");

			HSSFCell cell3 = headrow.createCell((short) 3);
			cell3.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell3.setCellStyle((HSSFCellStyle) headcellstyle);
			cell3.setCellValue("商品分类");

			HSSFCell cell4 = headrow.createCell((short) 4);
			cell4.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell4.setCellStyle((HSSFCellStyle) headcellstyle);
			cell4.setCellValue("商品型号");

			HSSFCell cell5 = headrow.createCell((short) 5);
			cell5.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell5.setCellStyle((HSSFCellStyle) headcellstyle);
			cell5.setCellValue("账单金额（元）");

			HSSFCell cell6 = headrow.createCell((short) 6);
			cell6.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell6.setCellStyle((HSSFCellStyle) headcellstyle);
			cell6.setCellValue("账单生成时间");

			HSSFCell cell7 = headrow.createCell((short) 7);
			cell7.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			cell7.setCellStyle((HSSFCellStyle) headcellstyle);
			cell7.setCellValue("账单备注");

			hsfe.setColumnWidth(Short.parseShort(0 + ""), Short
					.parseShort(1500 + ""));
			hsfe.setColumnWidth(Short.parseShort(1 + ""), Short
					.parseShort(3500 + ""));
			hsfe.setColumnWidth(Short.parseShort(2 + ""), Short
					.parseShort(4500 + ""));
			hsfe.setColumnWidth(Short.parseShort(3 + ""), Short
					.parseShort(3800 + ""));
			hsfe.setColumnWidth(Short.parseShort(4 + ""), Short
					.parseShort(4800 + ""));
			hsfe.setColumnWidth(Short.parseShort(5 + ""), Short
					.parseShort(4800 + ""));
			hsfe.setColumnWidth(Short.parseShort(6 + ""), Short
					.parseShort(7000 + ""));
			hsfe.setColumnWidth(Short.parseShort(7 + ""), Short
					.parseShort(7800 + ""));

			Float totalSale = 0.0f;

			for (int iIndex = 0; iIndex < list.size(); iIndex++)
			{
				JomooAccount ojc = (JomooAccount) list.get(iIndex);

				HSSFRow rows = hsfe.createRow(iIndex + 1);
				rows.setHeight((short) 350);

				HSSFCell hssfCell0 = rows.createCell((short) 0);
				hssfCell0.setCellStyle((HSSFCellStyle) numStyle);
				hssfCell0.setCellValue(iIndex + 1);

				/** 账单类型 */
				HSSFCell hssfCell1 = rows.createCell((short) 1);
				hssfCell1.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell1.setCellStyle((HSSFCellStyle) style);
				hssfCell1.setCellValue(ojc.getAccountTypeName() == null ? "--" : ojc
						.getAccountTypeName());

				/** 结算状态*/
				HSSFCell hssfCell2 = rows.createCell((short) 2);
				hssfCell2.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell2.setCellStyle((HSSFCellStyle) style);
				
				if(1 == ojc.getIsBalance())
				{
					hssfCell2.setCellValue("已结算");
				}
				
				if(0 == ojc.getIsBalance())
				{
					hssfCell2.setCellValue("未结算");
				}
				
				if(10 == ojc.getIsBalance())
				{
					hssfCell2.setCellValue("不计入结算");
				}
				
				/** 商品分类 */
				HSSFCell hssfCell3 = rows.createCell((short) 3);
				hssfCell3.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell3.setCellStyle((HSSFCellStyle) style);
				hssfCell3.setCellValue(ojc.getProductTypeName() == null ? "--"
						: ojc.getProductTypeName());

				/** 商品型号 */
				HSSFCell hssfCell4 = rows.createCell((short) 4);
				hssfCell4.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell4.setCellStyle((HSSFCellStyle) style);
				hssfCell4.setCellValue(ojc.getProductSpecName() == null ? "--"
						: ojc.getProductSpecName());

				/** 客户地址 */
				HSSFCell hssfCell5 = rows.createCell((short) 5);
				hssfCell5.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell5.setCellStyle((HSSFCellStyle) style);
				hssfCell5.setCellValue(ojc.getAccountSale().toString() == null ? "--" : ojc
						.getAccountSale().toString());

				/** 安装状态 */
				HSSFCell hssfCell6 = rows.createCell((short) 6);
				hssfCell6.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell6.setCellStyle((HSSFCellStyle) style);
				hssfCell6.setCellValue(format.format(ojc.getAccountTime()) == null ? "--"
						: format.format(ojc.getAccountTime()));
				
				/** 预约/维修时间 */
				HSSFCell hssfCell7 = rows.createCell((short) 7);
				hssfCell7.setEncoding((short) HSSFCell.ENCODING_UTF_16);
				hssfCell7.setCellStyle((HSSFCellStyle) style);
				hssfCell7
						.setCellValue(ojc.getRemark() == null ? "--"
								: ojc.getRemark());
				
				if (null != ojc.getAccountSale())
				{
					totalSale += ojc.getAccountSale();
				}

			}

			/** 创建统计数据行 */
			HSSFRow Totalrows = hsfe.createRow(list.size() + 1);

			HSSFCell hssfCell0 = Totalrows.createCell((short) 0);
			hssfCell0.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell0.setCellStyle((HSSFCellStyle) style);
			hssfCell0.setCellValue("合计");

			/** 客户姓名 */
			HSSFCell hssfCell1 = Totalrows.createCell((short) 1);
			hssfCell1.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell1.setCellStyle((HSSFCellStyle) style);
			hssfCell1.setCellValue("--");

			/** 客户电话 */
			HSSFCell hssfCell2 = Totalrows.createCell((short) 2);
			hssfCell2.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell2.setCellStyle((HSSFCellStyle) style);
			hssfCell2.setCellValue("--");

			/** 商品分类 */
			HSSFCell hssfCell3 = Totalrows.createCell((short) 3);
			hssfCell3.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell3.setCellStyle((HSSFCellStyle) style);
			hssfCell3.setCellValue("--");

			/** 商品型号 */
			HSSFCell hssfCell4 = Totalrows.createCell((short) 4);
			hssfCell4.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell4.setCellStyle((HSSFCellStyle) style);
			hssfCell4.setCellValue("--");

			/** 客户地址 */
			HSSFCell hssfCell5 = Totalrows.createCell((short) 5);
			hssfCell5.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell5.setCellStyle((HSSFCellStyle) style);
			hssfCell5.setCellValue(totalSale.toString());

			/** 安装状态 */
			HSSFCell hssfCell6 = Totalrows.createCell((short) 6);
			hssfCell6.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell6.setCellStyle((HSSFCellStyle) style);
			hssfCell6.setCellValue("--");

			/** 预约/维修时间 */
			HSSFCell hssfCell7 = Totalrows.createCell((short) 7);
			hssfCell7.setEncoding((short) HSSFCell.ENCODING_UTF_16);
			hssfCell7.setCellStyle((HSSFCellStyle) style);
			hssfCell7.setCellValue("--");


			hsf.write(out);

			out.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
			log.error("服务卡导出异常：" + e.getMessage());
		}
	}
}
